<template>
  <van-nav-bar
      title="支付"
      left-text=""
      left-arrow
      @click-left="onClickLeft"
  />
  <div class="pay-page">
    <!-- 金额区域 -->
    <div class="amount-section">
      <p>应付金额</p>
      <h1 class="price">¥ {{ money }}</h1>
    </div>

    <!-- 支付方式 -->
    <div class="pay-methods">
      <transition-group name="fade" tag="div">
        <div
            v-for="item in methods"
            :key="item.value"
            class="pay-card"
            :class="{ active: selected === item.value }"
            @click="selected = item.value"
        >
          <div class="left">
            <img :src="item.icon" />
            <span>{{ item.label }}</span>
          </div>
          <div class="check" v-if="selected === item.value">✓</div>
        </div>
      </transition-group>
    </div>

    <!-- 支付按钮 -->
    <div class="footer">
      <button @click="confirmPay">立即支付</button>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import {useRouter} from "vue-router";
const router = useRouter()
const myChannel=window.MyChannel;
console.log("myChannel=",myChannel)
function onClickLeft() {
  router.back()

}



const money = router.currentRoute.value.query.money;

const methods = [
  {
    label: '微信支付',
    value: 'wechat',
    icon: 'https://img.yzcdn.cn/vant/pay/wechat.png'
  },
  {
    label: '支付宝支付',
    value: 'alipay',
    icon: 'https://img.yzcdn.cn/vant/pay/alipay.png'
  }
]

const selected = ref('wechat')

function confirmPay() {
  alert(`跳转 ${selected.value === 'wechat' ? '微信' : '支付宝'} 支付...`)
}
</script>

<style scoped>
/* 整体页面 */
.pay-page {
  min-height: 100vh;
  background: #f6faff;
  display: flex;
  flex-direction: column;
}

/* 金额展示区 */
.amount-section {
  padding: 40px 20px 30px;
  background: linear-gradient(135deg, #4facfe, #00f2fe);
  color: white;
  text-align: center;
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
  box-shadow: 0 8px 20px rgba(0, 200, 255, 0.2);
}
.amount-section p {
  font-size: 15px;
  opacity: 0.9;
}
.amount-section .price {
  font-size: 40px;
  font-weight: 700;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.9; }
  100% { transform: scale(1); opacity: 1; }
}

/* 支付方式列表 */
.pay-methods {
  padding: 20px;

}
.pay-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: #fff;
  border-radius: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.3s ease;
  cursor: pointer;
  border: 2px solid transparent;
}
.pay-card.active {
  border-color: #4facfe;
  box-shadow: 0 2px 12px rgba(79, 172, 254, 0.3);
}
.pay-card .left {
  display: flex;
  align-items: center;
}
.pay-card img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  margin-right: 12px;
}
.pay-card span {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}
.pay-card .check {
  font-size: 18px;
  color: #4facfe;
}

/* 底部按钮 */
.footer {
  padding: 16px 20px;
  background: #fff;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.04);
}
.footer button {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: bold;
  border: none;
  border-radius: 28px;
  background: linear-gradient(to right, #4facfe, #00f2fe);
  color: white;
  box-shadow: 0 4px 14px rgba(79, 172, 254, 0.4);
  transition: background 0.3s;
}
.footer button:hover {
  background: linear-gradient(to right, #00f2fe, #4facfe);
}

/* 卡片渐变动画 */
.fade-enter-active,
.fade-leave-active {
  transition: all 0.3s;
}
.fade-enter-from,
.fade-leave-to {
  opacity: 0;
  transform: translateY(10px);
}
</style>
